package com.cskaoyan.market.service.impl;

import com.cskaoyan.market.db.domain.SelfMarketOrderGoodsInfo;
import com.cskaoyan.market.db.domain.SelfMarketOrderInfo;
import com.cskaoyan.market.db.mapper.MarketKeywordMapper;
import com.cskaoyan.market.db.mapper.MarketUserMapper;
import com.cskaoyan.market.db.mapper.SelfMarketOrderGoodsMapper;
import com.cskaoyan.market.db.vo.Row;
import com.cskaoyan.market.service.MarketStatService;
import com.cskaoyan.market.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MarketStatServiceImpl implements MarketStatService {

    @Override
    public List<SelfMarketOrderGoodsInfo> getProductsInfo() {
        SqlSession session = MyBatisUtil.getSession();
        SelfMarketOrderGoodsMapper mapper = session.getMapper(SelfMarketOrderGoodsMapper.class);
        return mapper.selectOrderGoodsInfoForProductStat();
    }

    @Override
    public List<SelfMarketOrderInfo> getOrderInfo() {
        SqlSession session = MyBatisUtil.getSession();
        SelfMarketOrderGoodsMapper mapper = session.getMapper(SelfMarketOrderGoodsMapper.class);
        return mapper.selectOrderInfoForOrderStat();
    }

    @Override
    public Map<String, Object> user() {
        SqlSession session = MyBatisUtil.getSession();
        MarketUserMapper mapper = session.getMapper(MarketUserMapper.class);
        List<Row> rows=mapper.selectUser();
        System.out.println(rows);
        session.commit();
        session.close();
        Map<String,Object> map = new HashMap<>();
        String[] s={"day","users"};
        map.put("rows",rows);
        map.put("columns",s);
        return map;
    }
}
